package com.dream.zhujianjun;

import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Timer;

import com.dream.contacts.ContactLocaleUtils;
import com.dream.contacts.FullNameStyle;
import com.dream.contacts.SmartDial;
import com.dream.launcher.MainLayout;
import com.dream.launcher.ScreenIndicator;
import com.dream.launcher.Workspace;
import com.dream.pinyin.HanZiToPinYin;
import com.dream.contacts.SmartDialQuery;

import android.app.Activity;
import android.app.WallpaperManager;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Android_testActivity extends Activity {
	/** Called when the activity is first created. */

	static final String TAG = "Test";

	//slidingView begin 
	private ScreenIndicator mScreenIndicator;
	private Workspace mWorkspace; 
	private final int WALLPAPER_SCREENS_SPAN = 2;
	//slidingView end 
	
	EditText inputEtx = null;
	TextView resultTx = null;
	Button clickBtn = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		 
		//slidingView begin 
		setContentView(R.layout.workspace_test);
		mScreenIndicator = (ScreenIndicator) findViewById(R.id.screenIndicator);
		MainLayout mainLayout = (MainLayout)findViewById(R.id.workspace);
		mWorkspace = (Workspace)findViewById(R.id.ScrollLayoutTest);
		mWorkspace.setScreenIndicator(mScreenIndicator);
		mainLayout.setWorkspace(mWorkspace);
		//slidingView end 
		/*
		setContentView(R.layout.main);

		inputEtx = (EditText) findViewById(R.id.inputEtx);
		resultTx = (TextView) findViewById(R.id.result);
		clickBtn = (Button) findViewById(R.id.click);
		// pinyin
		clickBtn.setOnClickListener(smartdialClickListener);
		*/
	}
	
	//smartdial
	View.OnClickListener smartdialClickListener = new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			String smartdial = inputEtx.getText().toString();
			long beforeTime = System.currentTimeMillis();
			
			resultTx.setText(SmartDialQuery.getResult(Android_testActivity.this, smartdial));
			long afterTime = System.currentTimeMillis();
			Log.d(TAG, "pinyin total time ~~~ " + (afterTime - beforeTime));
		}
	};

	// pinyin2
	View.OnClickListener pinyinClickListener2 = new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			String pinyin = inputEtx.getText().toString();
			long beforeTime = System.currentTimeMillis();
			
			resultTx.setText(SmartDial.getPinyin(pinyin));
			long afterTime = System.currentTimeMillis();
			Log.d(TAG, "pinyin total time ~~~ " + (afterTime - beforeTime));
		}
	};

	// pinyin
	View.OnClickListener pinyinClickListener = new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			String pinyin = inputEtx.getText().toString();
			long beforeTime = System.currentTimeMillis();
			resultTx.setText(HanZiToPinYin.toPinYin(pinyin));
			long afterTime = System.currentTimeMillis();
			Log.d(TAG, "pinyin total time ~~~ " + (afterTime - beforeTime));
		}
	};
	
	//slidingView 
    private void setWallpaperDimension() {
        WallpaperManager wpm = (WallpaperManager) getSystemService(WALLPAPER_SERVICE);

        Display display = getWindowManager().getDefaultDisplay();
        boolean isPortrait = display.getWidth() < display.getHeight();

        final int width = isPortrait ? display.getWidth() : display.getHeight();
        final int height = isPortrait ? display.getHeight() : display.getWidth();
        wpm.suggestDesiredDimensions(width * WALLPAPER_SCREENS_SPAN, height);
    }

}